(function() {
  function Node(element) {
    this.element = element;
    this.next = null;
    this.pri = null;
  }

  function linkedList() {
    this.head = new Node("head");
    this.last = new Node("last");
  }

  linkedList.prototype.insert = function(element) {
    var node = new Node(element);
    if (this.last.pri&&this.head.next) {
        node.pri=this.last.pri;
        this.last.pri.next = node;
        this.last.pri = node;
    } else {
      this.head.next = node;
      this.last.pri = node;
    }

    // node.next=this.head.next;
    // this.head.next=node
    //node.next = this.head;
    //this.head=node;
  };

  linkedList.prototype.findLast = function() {
    var currentNode = this.head;
    while (currentNode.next) {
      currentNode = currentNode.next;
    }
    return currentNode;
  };

  linkedList.prototype.find = function(item) {
    var currentNode = this.head;
    while (currentNode.element != item) {
      currentNode = currentNode.next;
    }
    return  currentNode
  };

  linkedList.prototype.delete = function(element) {
    var node = this.find(element);
    if (node) {
      var pri = node.pri;
      var next= node.next;
      pri.next = node.next;
      next.pri=node.pri;
      delete curNode;
    }
  };

  //构造函数当类用（大写开头）
  window.fi.LinkedList = linkedList;
})();
